package com.xl.Test;

import com.xl.entity.User;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class StreamTest {

    public static void main(String[] args) {
        List<User> users = User.getUsers();
        System.out.println(users);
        //Comparator.comparing(User::getAge) 比较器默认是从小到大排序，使用reverse（）实现从大到小
        List<User> collect = users.stream().sorted(Comparator.comparing(User::getAge).reversed()).collect(Collectors.toList());
        System.out.println(collect);
    }

}
